#!/bin/bash
set -x

# 备份源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.$(date +%Y%m%d%H%M%S)

sources="
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ $(lsb_release -sc) main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ $(lsb_release -sc) main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ $(lsb_release -sc)-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ $(lsb_release -sc)-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ $(lsb_release -sc)-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ $(lsb_release -sc)-security main restricted universe multiverse
"


echo "${sources}" | sudo tee /etc/apt/sources.list

sudo apt install language-pack-zh-hans
sudo localectl set-locale LANG=zh_CN.UTF-8
sudo localectl set-keymap zh_CN

# 添加ros国内源
sudo sh -c 'echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt update && sudo apt upgrade -y

if [ $(lsb_release -sc) == "xenial" ]; then
	ros_version="kinetic"
else
	ros_version="indigo"
fi

sudo apt-get install ros-${ros_version}-desktop-full -y

sudo rosdep init
rosdep update

# 安装一些必要的模块: 编译， 声音
sudo apt install python-catkin-tools ros-kinetic-sound-play python-flask -y
